package com.yixing.tech.datasync.controller;

import com.yixing.tech.common.base.BaseControl;
import com.yixing.tech.common.base.BusinessException;
import com.yixing.tech.common.base.Rs;
import com.yixing.tech.datasync.service.InStockSyncService;
import com.yixing.tech.datasync.service.StockOutSyncService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;

/**
 * 同步接口暴露，可以手动调试
 *
 * @author yixing tech
 * @since 1.0.0
 */

@Slf4j
@CrossOrigin
@RestController
@RequestMapping(value = "/sync")
public class SyncController extends BaseControl {

    @Autowired
    private InStockSyncService rawInStockSyncService;

    @Resource
    private StockOutSyncService stockOutSyncService;

    @GetMapping("/syncRawInStock")
    public Rs<Object> syncRawInStock() throws BusinessException {
        rawInStockSyncService.syncRawInStock();
        return Rs.ok(true);
    }


    @GetMapping("/syncProductionInStock")
    public Rs<Object> syncProductionInStock() throws BusinessException {
        rawInStockSyncService.syncProductionInStock();
        return Rs.ok(true);
    }

    @GetMapping("/syncSalesReturnStock")
    public Rs<Object> syncSalesReturnStock() throws BusinessException {
        rawInStockSyncService.syncSalesReturnStock();
        return Rs.ok(true);
    }

    @GetMapping("/syncBillProdPick")
    public Rs<Object> syncBillProdPick() throws BusinessException {
        stockOutSyncService.syncBillProdPick();
        return Rs.ok(true);
    }

    @GetMapping("/syncBillSalesOutStock")
    public Rs<Object> syncBillSalesOutStock() throws BusinessException {
        stockOutSyncService.syncBillSalesOutStock();
        return Rs.ok(true);
    }

    @GetMapping("/syncBillSalesPackOutStock")
    public Rs<Object> syncBillSalesPackOutStock() throws BusinessException {
        stockOutSyncService.syncBillSalesPackOutStock();
        return Rs.ok(true);
    }
}
